package java111;

import java.util.Scanner;

public class Day4 {
    static class question1 {
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            // 注意 hasNext 和 hasNextLine 的区别
            while (in.hasNextInt()) { // 注意 while 处理多个 case
                int n = in.nextInt();
                int[][] arr = new int[n + 1][n + 1];
                solution(arr, n);
                for (int i = 1; i < arr.length; i++) {
                    for (int j = 1; j < i + 1; j++) {
                        System.out.printf(" %4d", arr[i][j]);
                    }
                    System.out.println();
                }
            }
        }

        public static void solution(int[][] arr, int n) {
            arr[1][1] = 1;

            for (int i = 2; i < arr.length; i++) {
                arr[i][1] = 1;
                arr[i][i] = 1;
                for (int j = 2; j < i; j++) {
                    arr[i][j] = arr[i - 1][j] + arr[i - 1][j - 1];
                }
            }
        }
    }
    static class question2 {
        public static int[] arr = new int[300];
        public static void init() {
            arr[0] = 1;
            arr[1] = 1;
            for (int i = 2; i < arr.length; i++) {
                arr[i] = arr[i - 1] + arr[i - 2];
            }
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            // 注意 hasNext 和 hasNextLine 的区别
            while (in.hasNextInt()) { // 注意 while 处理多个 case
                init();
                int n = in.nextInt();
                int index = 0, res = 0;
                for (int i = 0; i < arr.length - 1; i++) {
                    if ((arr[i] < n && arr[i + 1] > n) || arr[i] == n) {
                        index = i;
                        break;
                    }
                }
                int tmp1 = Math.abs(arr[index] - n);
                int tmp2 = Math.abs(arr[index + 1] - n);
                res = Math.min(tmp1, tmp2);
                System.out.println(res);
            }
        }
    }
}
